﻿using System.ComponentModel;

namespace RiskMan.DataClass.Models.Sterling
{
    /// <summary>
    /// Струтктура заявок
    /// </summary>
    public class SterlingOrderModel : INotifyPropertyChanged
    {
        #region private

        #region Required fields

        private string _side;
        private string _symbol;
        private string _account;
        private long _priceType;
        private string _tif;
        private long _quantity;
        private string _destination;
        private string _clOrderId;

        #endregion

        #region Additional order fields

        private double _lmtPrice;
        private long _display;
        private double _discretion;
        private string _execInst;
        private double _pegDiff;
        private double _trialAmt;
        private double _trialInc;
        private double _stpPrice;
        private long _minQuantity;
        private string _execBroker;
        private string _user;
        private string _currency;

        #endregion

        #region Options fields

        private string _openClose;
        private string _maturity;
        private string _putCall;
        private string _underLying;
        private string _coverUncover;
        private string _instrument;
        private double _strikePrice;

        #endregion

        #region Locate fields

        private string _locateBroker;
        private string _locateTime;
        private long _locateQty;

        #endregion

        #region For Replace only

        private string _listingExchange;

        #endregion

        #region Order Desk

        private long _parentRecordId;
        private string _batchId;

        #endregion

        #endregion

        #region public

        #region Required fields
        /// <summary>
        /// See section Side for values (page 20)
        /// </summary>
        public string Side
        {
            get { return _side; }
            set
            {
                if (_side != value)
                {
                    _side = value;
                    RaisePropertyChanged("Side");
                }
            }
        }
        /// <summary>
        /// The options or equities symbol.
        /// </summary>
        public string Symbol
        {
            get { return _symbol; }
            set
            {
                if (_symbol != value)
                {
                    _symbol = value;
                    RaisePropertyChanged("Symbol");
                }
            }
        }
        /// <summary>
        /// The account exactly as it appears in Sterling.
        /// </summary>
        public string Account
        {
            get { return _account; }
            set
            {
                if (_account != value)
                {
                    _account = value;
                    RaisePropertyChanged("Account");
                }
            }
        }
        /// <summary>
        /// See Price Types for values (page 20)
        /// </summary>
        public long PriceType
        {
            get { return _priceType; }
            set
            {
                if (_priceType != value)
                {
                    _priceType = value;
                    RaisePropertyChanged("PriceType");
                }
            }
        }
        /// <summary>
        /// See TIF for values (page 20).
        /// </summary>
        public string Tif
        {
            get { return _tif; }
            set
            {
                if (_tif != value)
                {
                    _tif = value;
                    RaisePropertyChanged("Tif");
                }
            }
        }
        /// <summary>
        /// The number of shares (or contracts)
        /// </summary>
        public long Quantity
        {
            get { return _quantity; }
            set
            {
                if (_quantity != value)
                {
                    _quantity = value;
                    RaisePropertyChanged("Quantity");
                }
            }
        }
        /// <summary>
        /// The destination as it appears on the Sterling system ex. ARCA
        /// </summary>
        public string Destination
        {
            get { return _destination; }
            set
            {
                if (_destination != value)
                {
                    _destination = value;
                    RaisePropertyChanged("Destination");
                }
            }
        }
        /// <summary>
        /// Recommended field. Use this field to track orders (page 5)
        /// </summary>
        public string ClOrderId
        {
            get { return _clOrderId; }
            set
            {
                if (_clOrderId != value)
                {
                    _clOrderId = value;
                    RaisePropertyChanged("ClOrderId");
                }
            }
        }

        #endregion

        #region Additional order fields
        /// <summary>
        /// If price type is set to ptSTILmt this will be the limit value.
        /// </summary>
        public double LmtPrice
        {
            get { return _lmtPrice; }
            set
            {
                if (_lmtPrice != value)
                {
                    _lmtPrice = value;
                    RaisePropertyChanged("LmtPrice");
                }
            }
        }
        /// <summary>
        /// Send Hidden (0), Reserve (qty displayed) and visible if blank
        /// </summary>
        public long Display
        {
            get { return _display; }
            set
            {
                if (_display != value)
                {
                    _display = value;
                    RaisePropertyChanged("Display");
                }
            }
        }
        /// <summary>
        ///Price discretion on a limit order.
        /// </summary>
        public double Discretion
        {
            get { return _discretion; }
            set
            {
                if (_discretion != value)
                {
                    _discretion = value;
                    RaisePropertyChanged("Discretion");
                }
            }
        }
        /// <summary>
        ///Field for specifying Special Order Designations (see page 23)
        /// </summary>
        public string ExecInst
        {
            get { return _execInst; }
            set
            {
                if (_execInst != value)
                {
                    _execInst = value;
                    RaisePropertyChanged("ExecInst");
                }
            }
        }

        /// <summary>
        ///PEG-If price type is set to ptSTIPegged this will be the discretion
        /// </summary>
        public double PegDiff
        {
            get { return _pegDiff; }
            set
            {
                if (_pegDiff != value)
                {
                    _pegDiff = value;
                    RaisePropertyChanged("PegDiff");
                }
            }
        }

        /// <summary>
        ///T-STP-Amount by which you want to trail the last.
        /// </summary>
        public double TrialAmt
        {
            get { return _trialAmt; }
            set
            {
                if (_trialAmt != value)
                {
                    _trialAmt = value;
                    RaisePropertyChanged("TrialAmt");
                }
            }
        }

        /// <summary>
        ///T-STP-The value change needed to trigger an update on the trigger price.
        /// </summary>
        public double TrialInc
        {
            get { return _trialInc; }
            set
            {
                if (_trialInc != value)
                {
                    _trialInc = value;
                    RaisePropertyChanged("TrialInc");
                }
            }
        }

        /// <summary>
        ///STP-The trigger price on a STP or S-STP order.
        /// </summary>
        public double StpPrice
        {
            get { return _stpPrice; }
            set
            {
                if (_stpPrice != value)
                {
                    _stpPrice = value;
                    RaisePropertyChanged("StpPrice");
                }
            }
        }

        /// <summary>
        ///Minimum Fill quantity
        /// </summary>
        public long MinQuantity
        {
            get { return _minQuantity; }
            set
            {
                if (_minQuantity != value)
                {
                    _minQuantity = value;
                    RaisePropertyChanged("MinQuantity");
                }
            }
        }

        /// <summary>
        ///Preference
        /// </summary>
        public string ExecBroker
        {
            get { return _execBroker; }
            set
            {
                if (_execBroker != value)
                {
                    _execBroker = value;
                    RaisePropertyChanged("ExecBroker");
                }
            }
        }

        /// <summary>
        ///(Client-defined field)
        /// </summary>
        public string User
        {
            get { return _user; }
            set
            {
                if (_user != value)
                {
                    _user = value;
                    RaisePropertyChanged("User");
                }
            }
        }

        /// <summary>
        ///
        /// </summary>
        public string Currency
        {
            get { return _currency; }
            set
            {
                if (_currency != value)
                {
                    _currency = value;
                    RaisePropertyChanged("Currency");
                }
            }
        }

        #endregion

        #region Options fields

        /// <summary>
        /// O=Open, C=Close
        /// </summary>
        public string OpenClose
        {
            get { return _openClose; }
            set
            {
                if (_openClose != value)
                {
                    _openClose = value;
                    RaisePropertyChanged("OpenClose");
                }
            }
        }

        /// <summary>
        /// YYYYMMDD
        /// </summary>
        public string Maturity
        {
            get { return _maturity; }
            set
            {
                if (_maturity != value)
                {
                    _maturity = value;
                    RaisePropertyChanged("Maturity");
                }
            }
        }

        /// <summary>
        ///P=Put, C=Call
        /// </summary>
        public string PutCall
        {
            get { return _putCall; }
            set
            {
                if (_putCall != value)
                {
                    _putCall = value;
                    RaisePropertyChanged("PutCall");
                }
            }
        }

        /// <summary>
        ///Underlying equities Symbol
        /// </summary>
        public string UnderLying
        {
            get { return _underLying; }
            set
            {
                if (_underLying != value)
                {
                    _underLying = value;
                    RaisePropertyChanged("UnderLying");
                }
            }
        }

        /// <summary>
        ///C=Covered, U=Uncovered
        /// </summary>
        public string CoverUncover
        {
            get { return _coverUncover; }
            set
            {
                if (_coverUncover != value)
                {
                    _coverUncover = value;
                    RaisePropertyChanged("CoverUncover");
                }
            }
        }

        /// <summary>
        ///For instrument values (see page 22)
        /// </summary>
        public string Instrument
        {
            get { return _instrument; }
            set
            {
                if (_instrument != value)
                {
                    _instrument = value;
                    RaisePropertyChanged("Instrument");
                }
            }
        }

        /// <summary>
        /// Options strike price
        /// </summary>
        public double StrikePrice
        {
            get { return _strikePrice; }
            set
            {
                if (_strikePrice != value)
                {
                    _strikePrice = value;
                    RaisePropertyChanged("StrikePrice");
                }
            }
        }

        #endregion

        #region Locate fields
        
        /// <summary>
        /// Text field for Broker information.
        /// </summary>
        public string LocateBroker
        {
            get { return _locateBroker; }
            set
            {
                if (_locateBroker != value)
                {
                    _locateBroker = value;
                    RaisePropertyChanged("LocateBroker");
                }
            }
        }
        
        /// <summary>
        /// Text field for locate time information.
        /// </summary>
        public string LocateTime
        {
            get { return _locateTime; }
            set
            {
                if (_locateTime != value)
                {
                    _locateTime = value;
                    RaisePropertyChanged("LocateTime");
                }
            }
        }
        
        /// <summary>
        /// Text field for locate quantity information.
        /// </summary>
        public long LocateQty
        {
            get { return _locateQty; }
            set
            {
                if (_locateQty != value)
                {
                    _locateQty = value;
                    RaisePropertyChanged("LocateQty");
                }
            }
        }
           
        #endregion

        #region For Replace only

        
        /// <summary>
        /// The listing exchange.
        /// </summary>
        public string ListingExchange
        {
            get { return _listingExchange; }
            set
            {
                if (_listingExchange != value)
                {
                    _listingExchange = value;
                    RaisePropertyChanged("ListingExchange");
                }
            }
        }
           

        #endregion

        #region Order Desk

        
        /// <summary>
        /// RecordId of the order to be replaced.
        /// </summary>
        public long ParentRecordId
        {
            get { return _parentRecordId; }
            set
            {
                if (_parentRecordId != value)
                {
                    _parentRecordId = value;
                    RaisePropertyChanged("ParentRecordId");
                }
            }
        }
        
        /// <summary>
        /// Used when splitting orders in the order desk manager
        /// </summary>
        public string BatchID
        {
            get { return _batchId; }
            set
            {
                if (_batchId != value)
                {
                    _batchId = value;
                    RaisePropertyChanged("BatchID");
                }
            }
        }

        #endregion

        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
